package com.qd.common.panda.domain.entity.stroke;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;

/**
 * @author sjk
 */
@Data
@Accessors(chain = true)
@ToString
public class PayResult {
    private static final String SUCCESS = "SUCCESS";
    /**
     * 0支付结果通知 1退款结果通知
     */
    private int state;
    /**
     * 服务端订单唯一编号
     */
    private String orderId;
    /**
     * 第三方订单唯一编号
     */
    private String thirdPartyOrder;
    /**
     * 支付金额
     */
    private BigDecimal payAmount;
    /**
     * SUCCESS成功 FAIL失败
     */
    private String resultCode;
    /**
     * 支付时间
     */
    private String timeEnd;
    /**
     * 退款金额
     */
    private int refundFee;
    /**
     * 退款编号
     */
    private int refundNo;
    /**
     * 退款原因
     */
    private String refundReason;
    /**
     * 附加参数
     */
    private JsonNode attach;


    public boolean isSuccess() {
        return resultCode.equals(SUCCESS);
    }

    public void freeData() {
        this.orderId = null;
        this.thirdPartyOrder = null;
        this.payAmount = null;
        this.resultCode = null;
        this.timeEnd = null;
        this.attach = null;
        this.refundReason = null;
    }
}
